#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QtCore>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QList>
#include <QDebug>
#include <QStringList>
#include <QTimer>
#include <QScrollBar>
#include <QLabel>
#include "hexconvertor.h"
#include "testthread.h"
#include "serialmanager.h"
#include "keypresshandler.h"
#include <QThread>
#include <QButtonGroup>
#include <QMenu>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);

    ~Widget();
protected slots:
    void on_timer1();
    void onError(int error,QString msg);

private slots:
    //打开串口
    void on_btn_OpenPort_clicked();
    void display_data(QByteArray data_hex,QByteArray data_str);

     void on_cal(bool );

    void on_cbb_PortName_currentTextChanged(const QString &arg1);

    void on_btn_ClearRec_clicked();


    void on_btn_Send_clicked();

    void on_cbx_HexTransmit_toggled(bool checked);
    void on_settingGroup(QAbstractButton* btn,bool checked);

    void on_Spx_AlignBytes_editingFinished();

    void on_cbb_BaudRate_currentTextChanged(const QString &baud);

    void on_cbb_StopBits_currentIndexChanged(int index);

    void on_cbb_DataBits_currentTextChanged(const QString &arg1);

    void on_cbb_ParityBit_currentIndexChanged(int index);

    void on_btn_ClearTransmit_clicked();

signals:
    void serial_send(QByteArray data);
private:
    Ui::Widget *ui;
    QTimer *timer1;
    QString current_portName;
    QStringList ports_str;
    QSerialPort *comPort;
    SerialManager *testObj;
    QButtonGroup *btn_settingGroup;
    int recive_num;
    bool isPortOpen;
    bool isSendhex;
    bool isUpdatePortInfo;
    QThread thread;
    KeyPressHandler  pressHander ;
    uint alignLen;
    quint64 transmit_total;

};

#endif // WIDGET_H
